home *** CD-ROM | disk | FTP | other *** search
- Path: news.aimnet.com!news
- From: Ramnivas Laddad <ramnivas@digit.com>
- Newsgroups: comp.lang.c++
- Subject: Re: mixing static and const qualifiers for class members
- Date: 14 Mar 1996 03:03:42 GMT
- Organization: Aimnet Information Services
- Message-ID: <4i82ae$cq3@news.aimnet.com>
- References: <4i6mu3$pmg@halon.vggas.com>
- NNTP-Posting-Host: ren.digit.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.3 sun4c)
- X-URL: news:4i6mu3$pmg@halon.vggas.com
-
- For integers simply use enum
- class Foo
- {
- enum { nPositions = 6};
- int nData[nPositions];
- }
-
- For other than integer type, decalre const static in class definition
- and initialize it in one of the implementation file (typically, where
- Foo is implemented)
-
- // Foo.h
- class Foo
- {
- const static double d;
- };
-
- // Foo.cpp
-
- const double Foo::d = 5.8627675789;
-
-